import {defineStore} from "pinia";
import {computed, ref} from "vue";

export const useGoodsStore = defineStore('goods', () => {
    const goods = ref('');
    //返回goods
    const goodsInfo = computed(() => goods.value);

    //更新goods
    function updateGoods(u) {
        goods.value = u;
    }

    //重置goods
    function $reset() {
        goods.value = null;
    }

    return {goods, goodsInfo, updateGoods, $reset};
}, {
    persist: {
        key: 'goods',
        storage: sessionStorage,
    }
});